<template>
	<view class="body">
		<xk-header title="意见反馈处理"></xk-header>

		<view class="list" >
			<view class="list-item header" @click="more = !more">
				<view>工单信息:  {{pmFeedback.apply_no}}</view>
				<image v-if="!more" :src="(imgUrl+'/wx/up.png')"></image>
				<image v-else  :src="(imgUrl+'/wx/down.png')"></image>
			</view>
			<view v-if="more" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">反馈类型：</view>{{feedBackType[pmFeedback.fb_type]}}</view>
					<view class="info-item"><view class="key">空间区域：</view>{{pmFeedback.fb_address}}</view>
					<view class="info-item"><view class="key">反馈问题：</view>{{pmFeedback.fb_desc}}</view>
					<view class="info-item"><view class="key">反馈人：</view>{{pmFeedback.apply_user || '暂无'}}</view>
					<view class="info-item"><view class="key">业主单位：</view>{{pmFeedback.apply_company_name || '暂无'}}</view>
					<view class="info-item"><view class="key">联系电话：</view>{{pmFeedback.apply_phone || '暂无'}}</view>
					<view class="info-item"><view class="key">反馈时间：</view>{{pmFeedback.apply_date}}</view>
					<view v-if="pmFeedback.fb_pic" class="info-item"><view class="key"></view>
						<image-list :pics="pmFeedback.fb_pic"></image-list>
					</view>
				</view>
			</view>
		</view>
		<view v-if="pmFeedback.check_result" class="list" >
			<view class="list-item header" @click="backMore = !backMore">
				<view>抽查退回</view>
				<image v-if="!backMore" :src="(imgUrl+'/wx/up.png')"></image>
				<image v-else  :src="(imgUrl+'/wx/down.png')"></image>
			</view>
			<view v-if="backMore" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">查验人：</view>{{pmFeedback.check_user_name}}</view>
					<view class="info-item"><view class="key">查验部门：</view>{{pmFeedback.check_dept_name}}</view>
					<view class="info-item"><view class="key">查验日期：</view>{{pmFeedback.check_date}}</view>
					<view class="info-item">
						<view class="key">查验结果：</view>
						<text style="color: #FF3737;">{{pmFeedback.check_result == '20' ? '退回' : '通过'}}</text>
					</view>
					<view class="info-item"><view class="key">联系电话：</view>{{pmFeedback.apply_phone}}</view>
					<view class="info-item"><view class="key">反馈时间：</view>{{pmFeedback.apply_date}}</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="list-item header">
				<view>处理结果</view>
			</view>
			<view>
				<!-- <view class="list-item">
					<view>接单人：{{pmFeedback.followman}}</view>
				</view>
				<view class="list-item">
					<view>受理时间：2021-05-20 10:00</view>
				</view>
				<view class="list-item">
					<view>受理部门：保洁部</view>
				</view> -->
				<!-- <picker :value="doneResult" @change="doneResultChange"> -->
				<!-- <biaofun-datetime-picker :defaultValue="defaultDate"
					start="2000-02-03 00:00"
					end="2200-10-28 23:59"
					fields="minute"
					@change="dealTimeChange"
				>
					<view class="list-item">
						<view>处理时间<text class="com-req"></text>：</view>
						<view :class="formData.deal_time ? 'right-title1' : 'right-title1 right-title1-empty'">{{formData.deal_time ? formData.deal_time : "请选择处理时间"}}</view>
						<image mode="aspectFill" class="jiantou" src="/static/jiantou.png"/>
					</view>
				</biaofun-datetime-picker> -->
				<picker mode="date" :value="formData.deal_time" @change="dealTimeChange">
					<view class="list-item">
						<view>处理时间<text class="com-req"></text>：</view>
						<view :class="formData.deal_time ? 'right-title1' : 'right-title1 right-title1-empty'">
							{{ formData.deal_time ? formData.deal_time : "请选择" }}</view>
						<image mode="aspectFill" class="jiantou" :src="(imgUrl+'/wx/jiantou.png')" />
					</view>
				</picker>
				<view class="list-item textarea">
					<view>处理方案<text class="com-req"></text>：</view>
					<textarea v-model="formData.treatment" placeholder="在此输入处理方式" placeholder-class="placeholder"/>
				</view>
				<view class="list-item textarea">
					<view>备注：</view>
					<textarea v-model="formData.deal_remark" placeholder="在此输入备注" placeholder-class="placeholder"/>
				</view>
			</view>
		</view>
		<view class="from-item upload-img-item">
			<view class="title">上传处理照片</view>
			<!-- <view class="sub-title">请按要求上传图片，支持JPG/PNG格式</view>
			<view class="add-img-view" @click="onTakePhoto()">
				<image mode="aspectFill" class="add-img" src="/static/add-picture.png"/>
				<view>最多上传9张图片</view>
			</view>

			<view class="add-img-view" v-if="uploadImgs.length > 0">
				<view v-for="(item, index) of uploadImgs" :key="index" class="add-img-view-item">
					<image class="add-item" mode="aspectFill" :src="item"/>
					<image mode="widthFix" class="del-img" src="/static/delete.png"/>
				</view>
			</view> -->
			<upload-image :images="formData.deal_pic" @onChange="uploadImageChange"/>
		</view>
		<view class="common-bottom-view">
			<view class="common-btn" @click="doneRepair">提交</view>
		</view>
		<view class="common-zw"></view>
	</view>
</template>

<script>
	import moment from 'moment';
	export default {
		data() {
			return {
				imgUrl:this.$config.BASE_imgUrl,
				backMore: true,
				more: true,
				doneResult: '',
				uploadImgs: [
					this.$config.BASE_imgUrl+"/wx/temp/temp.jpeg",
					this.$config.BASE_imgUrl+"/wx/temp/temp.jpeg",
				],
				feedBackType: {},
				pmFeedback: {},
				defaultDate: moment().format('YYYY-MM-DD HH:mm'),
				formData: {
					pm_feedback_id: '',
					deal_time: '',
					treatment: '',
					deal_pic: '',
					deal_remark: '',
					isSubmit: true
				}
			};
		},
		computed:{
			fbType(){
				return this.feedBackType[this.pmFeedback.fb_type]
			}
		},
		onLoad(options){
			this.formData.pm_feedback_id = options.feedBackId;
			this.initConst();
		},
		methods:{
			initConst(){
				this.$util.initFeedbackType().then((res)=>{
					console.log('initFeedbackType', res)
					this.feedBackType = res;
					this.getFeedBackData();
				})
			},
			getFeedBackData(){
				this.$api.baseData_getPmFeedback(this.formData.pm_feedback_id).then((res)=>{
					this.pmFeedback = res.pmFeedback
				})
			},
			dealTimeChange(e){
				// console.log(e)
				this.formData.deal_time = moment(e.dt).format('YYYY-MM-DD HH:mm')
				// this.formData.deal_time = e.detail.value
			},
			uploadImageChange(images) {
				// console.warn("图片列表：", images)
				this.formData.deal_pic = images
			},
			doneRepair(){
				if(!this.formData.deal_time){
					this.$util.toast('请填写处理时间')
					return
				}
				if(!this.formData.treatment){
					this.$util.toast('请填写处理方案')
					return
				}

				this.$util.confirm({
					content: '确认提交处理结果'
				}).then(isConfirm => {
					if (isConfirm) {
						this.$util.post({
							url: "app/pmFeedback/deal",
							data: this.formData
						}).then((res)=>{
							uni.redirectTo({
								url:'/pagesA/ideas-box/ideas-box-finish?type=done'
							})
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
@import '@/common/from.scss';

</style>
